# 将之前封装的MyMath类中的实例方法改为静态方法, 体会两者的区别.
from math import sqrt


class MyMath(object):

    @staticmethod
    def add(a, b):
        return int(a) + int(b)


    @staticmethod
    def sub(a, b):
        return int(a) - int(b)


    @staticmethod
    def mul(a, b):
        return int(a) * int(b)


    @staticmethod
    def div(a, b):
        return int(a) / int(b)


    @staticmethod
    def sqrt(a):
        return sqrt(a)


# 为上节课自定义类添加以下功能:
# 添加类属性
# 添加类私有属性
# 添加类方法或者类的私有属性
# 在__init__方法中初始化实例属性
# 在__init__方法中绑定私有实例属性
# 在自定义类中实现__str__, 自定义输出格式
class p_language(object):
    hard_to_learn = True
    classification = 'language'
    __source_code = 'sss'
    def __init__(self, obj):
        self.l = obj
        print(f"{self.l}是一种编程语言")


class i_language(p_language):
    def __init__(self, name):
        print(f"{name}是一种解释型语言")
        self.__hide = 666


    def __str__(self):
        return f'i_language：{self.__hide}'


class c_language(p_language):
    def __init__(self, name):
        print(f"{name}是一种编译型语言")


if __name__ == "__main__":
    python = p_language('python')
    go = p_language('go')
    python = i_language('python')
    go = c_language('go')
